package IO;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by ZC_zc on 2016/11/28.
 */
public class writeObject {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        List<String> test=new ArrayList<>();
        test.add("zhang");
        test.add("闯");
        test.add("格式化");

        String targetName="D:"+File.separator+"test"+File.separator+"writeObject.txt";

        FileOutputStream fileOutputStream=new FileOutputStream(targetName);
//
//        ObjectOutputStream objectOutputStream=new ObjectOutputStream(fileOutputStream);
//
//        objectOutputStream.writeObject(test);
//
//        objectOutputStream.close();

        OutputStreamWriter writer=new OutputStreamWriter(fileOutputStream,"utf-8");

        BufferedWriter bufferedWriter=new BufferedWriter(writer);

        writer.write(test.toString());

        writer.close();


//        FileInputStream fileInputStream=new FileInputStream(targetName);
//
//        ObjectInputStream objectInputStream=new ObjectInputStream(fileInputStream);
//
//        List list= (List) objectInputStream.readObject();
//
//        for (Object o:list){
//            System.out.println(o);
//        }
    }
}
